package com.zjf.carpark.service.impl;

import com.zjf.carpark.dao.OwnerMapper;
import com.zjf.carpark.entities.Owner;
import com.zjf.carpark.service.OwnerService;
import com.zjf.carpark.utils.MD5Util;
import static com.zjf.carpark.utils.CodeAndMessage.salt;
import com.zjf.carpark.vo.OwnerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @description:
 * @author: 张建飞
 * @createDate: 2019/12/21
 * @version: 1.0
 */
@Service
public class OwnerServiceImpl extends BaseServiceImpl<Owner> implements OwnerService {
    @Autowired
    private OwnerMapper ownerMapper;

    @Override
    public int selectByCarNum(String carNum) {
        return ownerMapper.selectByCarNum(carNum);
    }

    @Override
    public Owner login(String userName, String password) {
        String firstMD5 = MD5Util.md5(password);
        String secondMD5 = MD5Util.twoMd5Pwd(firstMD5,salt);
        return ownerMapper.login(userName,secondMD5);
    }

    @Override
    public List<Owner> selectAllByVO(OwnerVO ownerVO) {
        if("".equals(ownerVO.getOwnerTel()))
        {
            ownerVO.setOwnerTel(null);
        }
        return ownerMapper.selectAllByVO(ownerVO);
    }

    @Override
    public int countByVO(OwnerVO ownerVO) {
        return ownerMapper.countByVO(ownerVO);
    }

    @Override
    public Owner phoneLogin(String ownerTel) {
        return ownerMapper.phoneLogin(ownerTel);
    }
}
